<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>患者登录页面</title>
    <link rel="stylesheet" href="/static/bootstrap-5.3.0/css/bootstrap.css">
</head>
<body onload="loadForm()">
<form style="width: 400px; margin: 200px auto" method="post">
    <div class="mb-3">
        <label for="patientCardId" class="form-label">请输入身份证号</label>
        <input type="text" class="form-control" id="patientCardId" aria-describedby="idHelp" name="patientCardId">
    </div>
    <div class="mb-3">
        <label for="patientPassword" class="form-label">请输入密码</label>
        <input type="password" class="form-control" id="patientPassword" name="patientPassword">
    </div>
    <div class="mb-3 form-check">
        <input type="checkbox" class="form-check-input" id="exampleCheck1" onclick="saveForm()">
        <label class="form-check-label" for="exampleCheck1">记住我</label>
    </div>
    <button type="submit" class="btn btn-primary">提交</button>
    <input type="button" class="btn btn-primary" onclick="goRegister()" value="去注册">
</form>

<script>
    function goRegister() {
        window.location.href = "/patientRegister"
    }
    function saveForm() {
        if (document.getElementById('exampleCheck1').checked) {
            localStorage.setItem('patientCardId', document.getElementById('patientCardId').value);
            localStorage.setItem('patientPassword', document.getElementById('patientPassword').value);
        } else {
            localStorage.removeItem('patientCardId');
            localStorage.removeItem('patientPassword');
        }
    }

    function loadForm() {
        const patientCardId = localStorage.getItem('patientCardId');
        const patientPassword = localStorage.getItem('patientPassword');

        if (patientCardId && patientPassword) {
            document.getElementById('patientCardId').value = patientCardId;
            document.getElementById('patientPassword').value = patientPassword;
        }
    }
</script>
</body>
</html>
